<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<div id="page-content">
    <div class="row" style="margin-bottom:20px;">
        <div class="col-lg-12 col-sm-12 col-xs-12" id="todo_list">
            <div class="panel">
                <h3 class="panel_title">待办事宜</h3>
                <div class="col-sm-12 table-toolbar-right" style="position: absolute; right: 15px;top: 5px;">
                    <a  id="todo_more" class= btn-default" style="cursor:pointer;">
                        <img src="../resource/core/img/index/u56.png" width="50px"/>
                    </a>
                </div>
                <ul class="panel_ul">
                    <li>您的【报销申请】 FYBX201708291234 已被 王力宏 通过</li>
                    <li>您的【报销申请】 FYBX201708291234 已被 王力宏 通过</li>
                    <li>您的【报销申请】 FYBX201708291234 已被 王力宏 通过</li>
                    <li>您的【报销申请】 FYBX201708291234 已被 王力宏 通过</li>
                </ul>
                <div class="panel-body" id="todo_list_row">
                    <table id="todo_table">
                    </table>
                </div>
            </div>
        </div>
    </div>
    <div class="row" style="margin-bottom:20px;">
        <div class="col-lg-12 col-sm-12 col-xs-12" id="common_exam">
            <div class="panel">
                <h3 class="panel_title">常用审批</h3>

                <div class="col-sm-12 table-toolbar-right" style="position: absolute; right: 15px;top: 5px;">
                    <a  id="common_more" class= btn-default" style="cursor:pointer;">
                        <img src="../resource/core/img/index/u56.png" width="50px"/>
                    </a>
                </div>
                <div id="model_list">
                    <c:forEach var="item" items="${commonModelList}" varStatus="status">
                        <div class="panel_left">
                            <img src="../resource/core/img/index/u75.png" width="70px"/>
                            <p>${items.val1}<p>
                            <input type="hidden" name="commonId" value="${items.key1}" />
                        </div>
                    </c:forEach>

                </div>
                <div class="clear"></div>
            </div>
        </div>
    </div>
    <div class="row" style="margin-bottom:20px;">
        <div class="col-lg-12 col-sm-12 col-xs-12" id="news_list">
            <div class="panel">
                <h3 class="panel_title">新闻公告</h3>
                <div class="col-sm-12 table-toolbar-right" style="position: absolute; right: 15px;top: 5px;">
                    <a  id="notice_more" class= btn-default" style="cursor:pointer;">
                        <img src="../resource/core/img/index/u56.png" width="50px"/>
                    </a>
                </div>
                <ul class="panel_ul">
                    <li>我司产品自动烹饪机荣获2017年红点设计大奖金奖</li>
                    <li>我司产品自动烹饪机荣获2017年红点设计大奖金奖</li>
                    <li>我司产品自动烹饪机荣获2017年红点设计大奖金奖</li>
                    <li>我司产品自动烹饪机荣获2017年红点设计大奖金奖</li>
                </ul>
                <ul class="panel_ul">
                    <li>我司产品自动烹饪机荣获2017年红点设计大奖金奖</li>
                    <li>我司产品自动烹饪机荣获2017年红点设计大奖金奖</li>
                    <li>我司产品自动烹饪机荣获2017年红点设计大奖金奖</li>
                    <li>我司产品自动烹饪机荣获2017年红点设计大奖金奖</li>
                </ul>
                <div class="panel-body" id="notice_list_row">
                    <table id="notice_table">
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<script>

    $(function(){
        $('#page-content').on('click','#common_more',function(){
            var mids = "";
            $('input[name="commonId"]').each(function(){
                mids += $(this).val()+",";
            })
            mids = mids .substr(0,mids .length-1);
            __open_dialog_select('选择常用审批', '<%=path%>/main/getAllModel?mids='+mids, function (dialogRef) {
                var callback = function (data) {
                    if (data) {
                        //console.log(data)
                        var nameArr = data.names.split(",");
                        var idArr = data.ids.split(",");
                        if(nameArr == ""){
                            __toastr_warning("请至少选择一个常用模块");
                            dialogRef.enableButtons();
                            return false;
                        }
                        __ajax_post('<%=path%>/main/saveCommonModel',{"keys":data.ids,"vals": data.names},function(data){
                            if(data.state == 1){
                                var str = "";
                                for(var i=0; i< nameArr.length; i++) {
                                    str  += ' <div class="panel_left"><img src="../resource/core/img/index/u75.png" width="70px"/> <p>'+nameArr[i]+'</p>  <input type="hidden" name="commonId" value="'+idArr[i]+'" /></div>';
                                }
                                $('#model_list').html(str);
                                dialogRef.close();
                            }else{
                                __toastr_error("保存失败");
                                dialogRef.enableButtons();
                            }
                        });

                    } else {
                        dialogRef.enableButtons();
                    }
                };
                fn_dialog_models_select(callback);
            });
        });

       loadURL("<%=path%>/main/getCommonModel",$('#model_list'));
        $('#page-content').on("click",'.panel_left img',function(){
            var entityKey=$(this).parent().find(":input[name='commonId']").val();
            entityKey=entityKey.substring(entityKey.lastIndexOf(".")+1,entityKey.length);
            var a=entityKey.charAt(0).toLowerCase();
            entityKey=a+entityKey.substring(1,entityKey.length);
            loadURL("<%=path%>/com/"+entityKey+"/input", $('#page-content'));
        });

      //  load_todo();
      //  load_notice();
      //  load_norecord();
      //  load_record();
        $('#page-content').on("click",'#notice_more',function(){
            loadURL("menu/com/noticeTest?viewtype=2",$('#content-container'));
        });
        $('#page-content').on("click",'#remind_more',function(){
            loadURL("menu/remind",$('#content-container'));
        });
        $('#page-content').on("click",'#todo_more',function(){
            __open_dialog_form_read('待办事宜',"menu/toDo");
           // loadURL("menu/toDo",$('#content-container'));
        });
        $('#page-content').on("click",'#norecord_more',function(){
            loadURL("menu/taskRecord?type=1",$('#content-container'));
        });
        $('#page-content').on("click",'#record_more',function(){
            loadURL("menu/taskRecord?type=2",$('#content-container'));
        });


    })


    //公告通知
    function load_notice(){
        jQuery("#notice_table").jqGrid({
            url:'<%=path%>/com/noticeTest/list?viewtype=2',
            datatype: "json",
            colNames:['公告主题',"id"],
            colModel:[
                {name:'topic',index:'topic', width:200,search:false,sortable:false},
                {name:'id',index:'id',search:false,hidden:true,key:true}
            ],
            rowNum :5,
            // rowList:[10,20,30],
            //  pager : '#notice_list_page',
            sortname : '',
            sortorder : "",
            gridComplete:function(){
                $('#gview_notice_table a.ui-jqgrid-titlebar-close').hide();
                $('#gview_notice_table span.ui-jqgrid-title more').remove();
                $('#gview_notice_table span.ui-jqgrid-title').append('<more>More</more>') ;
                $(".ui-jqgrid-bdiv").css("overflow-x","hidden");
            },
            onSelectRow: function (rowId, status, e) {
                var rowId = $("#notice_table").jqGrid('getGridParam','selrow');
                var rowDatas = $("#notice_table").jqGrid('getRowData', rowId);
            },
            ondblClickRow:function(rowid, iRow, iCol, e){
                var rowId = $("#notice_table").jqGrid('getGridParam','selrow');
                var rowDatas = $("#notice_table").jqGrid('getRowData', rowId);
                if(rowId !="")
                loadURL('<%=path%>/com/noticeTest/read?keyId='+rowId+'&viewtype=2&index=1', $('#page-content'));
            },
            jsonReader: {
                root: "dataRows",
                page: "page",
                total: "total",
                records: "records",
                repeatitems : false
            },
         //   caption : "公告通知",
            multiselect : false,
            rownumbers:false,
            gridview:true,
            shrinkToFit:true,
            viewrecords: false,
            autowidth: true,
            height:'auto',
            forceFit:true,
            loadComplete: function() {
            }
        });
        $(window).on('resize.jqGrid', function() {
            jQuery("#notice_table").jqGrid('setGridWidth', $("#notice_list_row").width());
        })
        jQuery("#notice_table").jqGrid('filterToolbar',{searchOperators:false,stringResult:true});


    };

    //提醒事项
    function load_remind(){
        jQuery("#remind_table").jqGrid({
            url:'<%=path%>/main/remind/list',
            datatype: "json",
            colNames:['提醒内容',"id",'url'],
            colModel:[
                {name:'content',index:'content', width:200,search:false,sortable:false},
                {name:'id',index:'id',search:false,hidden:true,key:true},
                {name:'url',index:'url',search:false,hidden:true}
            ],
            rowNum :5,
            // rowList:[10,20,30],
            //  pager : '#notice_list_page',
            sortname : '',
            sortorder : "",
            gridComplete:function(){
                $('#gview_remind_table a.ui-jqgrid-titlebar-close').hide();
                $('#gview_remind_table span.ui-jqgrid-title more').remove();
                $('#gview_remind_table span.ui-jqgrid-title').append('<more>More</more>') ;
                $(".ui-jqgrid-bdiv").css("overflow-x","hidden");
            },
            onSelectRow: function (rowId, status, e) {
                var rowId = $("#remind_table").jqGrid('getGridParam','selrow');
                var rowDatas = $("#remind_table").jqGrid('getRowData', rowId);
            },
            ondblClickRow:function(rowid, iRow, iCol, e){
                var rowId = $("#remind_table").jqGrid('getGridParam','selrow');
                var rowDatas = $("#remind_table").jqGrid('getRowData', rowId);
                if(rowId !="")
                    loadURL(rowDatas.url+"&index=1",$('#page-content'));
            },
            jsonReader: {
                root: "dataRows",
                page: "page",
                total: "total",
                records: "records",
                repeatitems : false
            },
          //  caption : "提醒事项",
            multiselect : false,
            rownumbers:false,
            gridview:true,
            shrinkToFit:true,
            viewrecords: false,
            autowidth: true,
            height:'auto',
            forceFit:true,
            loadComplete: function() {
            }
        });
        $(window).on('resize.jqGrid', function() {
            jQuery("#remind_table").jqGrid('setGridWidth', $("#remind_list_row").width());
        })
        jQuery("#remind_table").jqGrid('filterToolbar',{searchOperators:false,stringResult:true});


    };

    //个人待办事项目
    function load_todo(){
        jQuery("#todo_table").jqGrid({
            url:'../main/taskRecord/toDoList',
            datatype: "json",
            colNames:['审核内容','所属模块','申请人','上一步操作人','时间','url',"id"],
            colModel:[
                {name:'pname',index:'pname', width:100,search:false,sortable:false},
                {name:'module',index:'module', width:60,search:false,sortable:false},
                {name:'creater',index:'creater', width:60,search:false,sortable:false},
                {name:'toUser',index:'toUser', width:80,search:false,sortable:false},
                {name:'time',index:'time', width:100,search:false,sortable:false},
                {name:'url',index:'url', width:0,search:false,sortable:false,hidden:true},
                {name:'docId',index:'docId',search:false,hidden:true,key:true}
            ],
            rowNum :5,
            // rowList:[10,20,30],
            //  pager : '#notice_list_page',
            sortname : '',
            sortorder : "",
            gridComplete:function(){
                $('#gview_todo_table a.ui-jqgrid-titlebar-close').hide();
                $('#gview_todo_table span.ui-jqgrid-title more').remove();
                $('#gview_todo_table span.ui-jqgrid-title').append('<more>More</more>') ;
                $(".ui-jqgrid-bdiv").css("overflow-x","hidden");

            },
            onSelectRow: function (rowId, status, e) {
                var rowId = $("#todo_table").jqGrid('getGridParam','selrow');
                var rowDatas = $("#todo_table").jqGrid('getRowData', rowId);
            },
            ondblClickRow:function(rowid, iRow, iCol, e){
                var rowId = $("#todo_table").jqGrid('getGridParam','selrow');
                var rowDatas = $("#todo_table").jqGrid('getRowData', rowId);
                if(rowId !="")
                    loadURL(rowDatas.url+"&index=1",$('#page-content'));
            },
            jsonReader: {
                root: "dataRows",
                page: "page",
                total: "total",
                records: "records",
                repeatitems : false
            },
          //  caption : "个人待办事项",
            multiselect : false,
            rownumbers:false,
            gridview:true,
            shrinkToFit:true,
            viewrecords: false,
            autowidth: true,
            height:'auto',
            forceFit:true,
            loadComplete: function() {
            }
        });
        $(window).on('resize.jqGrid', function() {
            jQuery("#todo_table").jqGrid('setGridWidth', $("#todo_list_row").width());
        })
        jQuery("#todo_table").jqGrid('filterToolbar',{searchOperators:false,stringResult:true});


    };


    //已办未结
    function load_norecord(){
        jQuery("#norecord_table").jqGrid({
            url:'<%=path%>/main/taskRecord/list?type=1',
            datatype: "json",
            colNames:['审核内容','所属模块','申请人','当前操作人','url',"id"],
            colModel:[
                {name:'pname',index:'pname', width:100,search:false,sortable:false},
                {name:'module',index:'module', width:60,search:false,sortable:false},
                {name:'creater',index:'creater', width:60,search:false,sortable:false},
                {name:'usernames',index:'usernames', width:100,search:false,sortable:false},
                {name:'url',index:'url', width:0,search:false,sortable:false,hidden:true},
                {name:'id',index:'id',search:false,hidden:true,key:true}
            ],
            rowNum :5,
            // rowList:[10,20,30],
            //  pager : '#notice_list_page',
            sortname : '',
            sortorder : "",
            gridComplete:function(){
                $('#gview_norecord_table a.ui-jqgrid-titlebar-close').hide();
                $('#gview_norecord_table span.ui-jqgrid-title more').remove();
                $('#gview_norecord_table span.ui-jqgrid-title').append('<more>More</more>') ;
                $(".ui-jqgrid-bdiv").css("overflow-x","hidden");

            },
            onSelectRow: function (rowId, status, e) {
                var rowId = $("#norecord_table").jqGrid('getGridParam','selrow');
                var rowDatas = $("#norecord_table").jqGrid('getRowData', rowId);
            },
            ondblClickRow:function(rowid, iRow, iCol, e){
                var rowId = $("#norecord_table").jqGrid('getGridParam','selrow');
                var rowDatas = $("#norecord_table").jqGrid('getRowData', rowId);
                if(rowId !="")
                    loadURL(rowDatas.url+"&index=1",$('#page-content'));
            },
            jsonReader: {
                root: "dataRows",
                page: "page",
                total: "total",
                records: "records",
                repeatitems : false
            },
          //  caption : "已办未结",
            multiselect : false,
            rownumbers:false,
            gridview:true,
            shrinkToFit:true,
            viewrecords: false,
            autowidth: true,
            height:'auto',
            forceFit:true,
            loadComplete: function() {
            }
        });
        $(window).on('resize.jqGrid', function() {
            jQuery("#norecord_table").jqGrid('setGridWidth', $("#norecord_list_row").width());
        })
        jQuery("#norecord_table").jqGrid('filterToolbar',{searchOperators:false,stringResult:true});


    };

    //已办已结
    function load_record(){
        jQuery("#record_table").jqGrid({
            url:'<%=path%>/main/taskRecord/list?type=2',
            datatype: "json",
            colNames:['审核内容','所属模块','url',"id"],
            colModel:[
                {name:'pname',index:'pname', width:200,search:false,sortable:false},
                {name:'module',index:'module', width:100,search:false,sortable:false},
                {name:'url',index:'url', width:0,search:false,sortable:false,hidden:true},
                {name:'id',index:'id',search:false,hidden:true,key:true}
            ],
            rowNum :5,
            // rowList:[10,20,30],
            //  pager : '#notice_list_page',
            sortname : '',
            sortorder : "",
            gridComplete:function(){
                $('#gview_record_table a.ui-jqgrid-titlebar-close').hide();
                $('#gview_record_table span.ui-jqgrid-title more').remove();
                $('#gview_record_table span.ui-jqgrid-title').append('<more>More</more>') ;
                $(".ui-jqgrid-bdiv").css("overflow-x","hidden");

            },
            onSelectRow: function (rowId, status, e) {
                var rowId = $("#record_table").jqGrid('getGridParam','selrow');
                var rowDatas = $("#record_table").jqGrid('getRowData', rowId);
            },
            ondblClickRow:function(rowid, iRow, iCol, e){
                var rowId = $("#record_table").jqGrid('getGridParam','selrow');
                var rowDatas = $("#record_table").jqGrid('getRowData', rowId);
                if(rowId !="")
                loadURL(rowDatas.url+"&index=1",$('#page-content'));
            },
            jsonReader: {
                root: "dataRows",
                page: "page",
                total: "total",
                records: "records",
                repeatitems : false
            },
         //   caption : "已办已结",
            multiselect : false,
            rownumbers:false,
            gridview:true,
            shrinkToFit:true,
            viewrecords: false,
            autowidth: true,
            height:'auto',
            forceFit:true,
            loadComplete: function() {
            }
        });
        $(window).on('resize.jqGrid', function() {
            jQuery("#record_table").jqGrid('setGridWidth', $("#record_list_row").width());
        })
        jQuery("#record_table").jqGrid('filterToolbar',{searchOperators:false,stringResult:true});


    };
</script>
